empty.graph(nodes, num = 1)
random.graph(nodes, num = 1, method = "ordered", ..., debug = FALSE)ordered (full ordering based generation), ic-dag
(Ide's and Cozman's Generating Multi-connected DAGs algorithm),
melancon (MTRUE a lot of debugging output is
printed; otherwise the function is completely silent. Ignored in some
generation methods.empty.graph and random.graph return an object of class
bn (if num is equal to 1) or a list of objects of class
bn (otherwise). If every is greated than 1,
random.graph always returns a list, regardless of the number of graphs
it contains.
ordered): generates
graphs whose node ordering is given by the order of the labels in thenodesparameter. The same algorithm is used in therandomDAGfunction in packageic-dag): generates graphs with a uniform probability
distribution over the set of multiconnected graphs.melancon): generates graphs with a uniform probability
distribution over the set of all possible graphs.empty): generates graphs without any arc. Additional parameters for the random.graph function are:
prob: the probability of each arc to be present in a graph
generated by theorderedalgorithm. The default value is2 / (length(nodes) - 1), which results in a sparse graph (the
number of arcs should be of the same order as the number of nodes).burn.in: the number of iterations for theic-dagandmelanconalgorithms to converge to a stationary (and uniform)
probability distribution. The default value is6 * length(nodes)^2.every: return only one grapheverynumber of steps
instead of all the graphs generated withic-dagandmelancon. Since both algorithms are based on Markov Chain Monte
Carlo approaches, high values ofeveryresult in a more diverse
set of networks. The default value is1, i.e. to return all the
networks that are generated.max.degree: the maximum degree for any node in a graph
generated by theic-dagandmelanconalgorithms. The default
value isInf.max.in.degree: the maximum in-degree for any node in a graph
generated by theic-dagandmelanconalgorithms. The default
value isInf.max.out.degree: the maximum out-degree for any node in a graph
generated by theic-dagandmelanconalgorithms. The default
value isInf.Melancon G, Dutour I, Bousquet-Melou M (2001). "Random Generation of Directed Acyclic Graphs". Electronic Notes in Discrete Mathematics, 10, 202-207.
Melancon G, Philippe F (2004). "Generating Connected Acyclic Digraphs Uniformly at Random". Information Processing Letters, 90(4), 209-213.
empty.graph(LETTERS[1:8])
random.graph(LETTERS[1:8])
plot(random.graph(LETTERS[1:8], method = "ic-dag", max.in.degree = 2))
plot(random.graph(LETTERS[1:8]))
plot(random.graph(LETTERS[1:8], prob = 0.2))Run the code above in your browser using DataLab